package com.mk.service.platform;

import act.controller.Controller;
import com.github.d925529.apidoc.ApiHttpMethod;
import com.github.d925529.apidoc.annotation.*;
import com.mk.domain.CpLogisticsConfig;
import com.mk.interceptor.ITranslate;
import com.mk.util.S2;
import org.osgl.mvc.annotation.GetAction;
import org.osgl.mvc.annotation.PostAction;
import org.osgl.mvc.annotation.PutAction;
import org.osgl.mvc.annotation.With;

import javax.inject.Inject;
import javax.validation.constraints.NotNull;

/**
 * 说明：物流配置表后台服务
 * 作者：292303959@qq.com 
 * 日期：2018-11-2 15:57:54 
 * 版本：1.0.0
 */
@Controller("cpLogisticsConfig")
@Api(group = "pl",title = "物流配置表服务", path = "/cpLogisticsConfig")
@SuppressWarnings("unused")
public class CpLogisticsConfigService extends BasePlatformService {
    @Inject
    private CpLogisticsConfig.Mapper cpLogisticsConfigMapper;


    @With({ILogin.class, ITranslate.class})
    @PostAction("add.json")
    @ApiMethod(title = "增加保存物流配置表", path = "/add.json", method = ApiHttpMethod.POST)
    @ApiParam(name = "cpLogisticsConfig", title = "物流配置表", type = CpLogisticsConfig.class)
    @ApiReturn(description = "主键", type = String.class)
    public String add(@NotNull CpLogisticsConfig cpLogisticsConfig) {
        String id = S2.UUID();
        cpLogisticsConfig.setLcid(id);
        cpLogisticsConfigMapper.insertTemplate(cpLogisticsConfig);
        return id;
    }


    @With({ILogin.class, ITranslate.class})
    @PutAction("update.json")
    @ApiMethod(title = "修改保存物流配置表", path = "/update.json", method = ApiHttpMethod.PUT)
    @ApiParam(name = "cpLogisticsConfig", title = "物流配置表", type = CpLogisticsConfig.class)
    @ApiReturn(description = "修改了的数量", type = int.class)
    public int update(@NotNull CpLogisticsConfig cpLogisticsConfig) {
        return cpLogisticsConfigMapper.updateTemplateById(cpLogisticsConfig);
    }

    @With(ILogin.class)
    @GetAction("view.json")
    @ApiMethod(title = "查询指定物流配置表", path = "/view.json", method = ApiHttpMethod.GET)
    @ApiParam(name = "id", title = "物流配置表的主键", type = String.class)
    @ApiReturn(description = "物流配置表", type = CpLogisticsConfig.class)
    public CpLogisticsConfig view(@NotNull String id){
        return cpLogisticsConfigMapper.single(id);
    }
}
